using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Gadgets.Setups
{
    public partial class eMenus : WeifenLuo.WinFormsUI.Docking.DockContent  
    {
        public eMenus()
        {
            InitializeComponent();
        }

        private void eMenus_Load(object sender, EventArgs e)
        {
            try
            {
                ABSCommonLibrary.CreateGridView(ref gridControl1);
            }
            catch (Exception ex)
            {
                ABSCommonLibrary.ShowErrorMessage(ex.ToString());
            }
        }
        private void LoadGrid()
        {
            DataSet tran_type = ABSCommonLibrary.DoInquiry(
                    CommonLibrary.CommonLibrary.BOSC019002, new object[1] { string.Empty });
            gridControl1.SetDataBinding(tran_type, tran_type.Tables[0].TableName);
        }
        private void eMenus_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.F11)
                {
                    if (((DataSet)gridControl1.DataSource).Tables[0].GetChanges() != null)
                    {
                        foreach (DataRow row in ((DataSet)gridControl1.DataSource).Tables[0].GetChanges().Rows)
                        {
                            if (row.RowState == DataRowState.Modified)
                            {
                                object[] p_param = new object[3];
                                p_param[0] = row["MENU_ID"];
                                p_param[1] = row["MENU_TEXT"];
                                p_param[2] = row["PARENT_ID"];
                                ABSCommonLibrary.DoExecute(
                                        CommonLibrary.CommonLibrary.BOSC019003, ref p_param);
                            }
                        }
                        LoadGrid();
                    }
                }
                else if (e.KeyCode == Keys.F9)
                    LoadGrid();
            }
            catch (Exception ex)
            {
                ABSCommonLibrary.ShowErrorMessage(ex.ToString());
            }
        }
    }
}